home *** CD-ROM | disk | FTP | other *** search
Wrap
trace var="form" category="Form" text="Form Data Passed" inline=true> <!--- We set a variable called formOK to true. If it becomes false, we know that _something_ went wrong ---> <cfset formOK = true> <!--- This string will contain all the error messages ---> <cfset errorMsg = ""> <!--- Must have first name, and can't contain funky stuff. Can only have a-z + "'" + spaces ---> <cfif not len(trim(form.firstName)) or REFindNoCase("[^a-z' ]",form.firstName)> <cfset errorMsg = errorMsg & "You must include your first name. It can only contain the characters a-z, apostrophe, and spaces.<br>"> <cfset formOK = false> </cfif> <cftrace var="formOK" category="Form Checking" text="After checking First Name" inline=true> <!--- Must have last name, and can't contain funky stuff. Can only have a-z + "'" + spaces ---> <cfif not len(trim(form.lastName)) or REFindNoCase("[^a-z' ]",form.lastName)> <cfset errorMsg = errorMsg & "You must include your last name. It can only contain the characters a-z, apostrophe, and spaces.<br>"> <cfset formOK = false> </cfif> <cftrace var="formOK" category="Form Checking" text="After checking Last Name" inline=true> <!--- Must have an age, and must be integer, > 0, lt 130 ---> <cfif not len(trim(form.age)) or not isNumeric(form.age) or form.age is not round(form.age) or form.age lte 0 or form.age gte 130> <cfset errorMsg = errorMsg & "You must include your age. It must be a whole number (no decimals allowed).<br>"> <cfset formOK = false> </cfif> <cftrace var="formOK" category="Form Checking" text="After checking Age" inline=true> <!--- Must pick at least one favorite film ---> <cfif not len(trim(form.favoriteFilms))> <cfset errorMsg = errorMsg & "You must pick at least one favorite film.<br>"> <cfset formOK = false> </cfif> <cftrace var="formOK" category="Form Checking" text="After checking Favorite Film" inline=true> <cfif formOK> <!--- Do something here, save it, whatever. ---> <cfoutput> <p> Thank you for filling out the form, #form.firstName# #form.lastName#. You may return to the <a href="index.cfm">original form</a> and try again. </p> </cfoutput> </cfif> </cfif> <!--- Only display form if you need to ---> <cfif not isDefined("formOK") or not formOK> <p> Please complete the form below. All fields are required. (<i>Although to make the CFTRACE information more interesting, you may want to purposely enter incorrect data!</i>) </p> <cfif isDefined("formOK")> <p> <cfoutput><font color="red">Please correct the following problems:<br>#errorMsg#</font></cfoutput> </p> </cfif> <cfoutput> <form action="index.cfm" method="post"> <table cellpadding=5> <tr> <td>First Name:</td> <td><input type="text" name="firstName" value="#form.firstName#"></td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="lastName" value="#form.lastName#"></td> </tr> <tr> <td>Age:</td> <td><input type="text" name="age" value="#form.age#"></td> </tr> <tr valign="top"> <td>Favorite Movies:</td> <td> <table width="100%" cellpadding=0 cellspacing=0> <tr valign="top"> <td><input type="checkbox" name="favoriteFilms" value="godfather" <cfif listFind(form.favoriteFilms,"godfather")>checked</cfif>>Godfather </td> <td><input type="checkbox" name="favoriteFilms" value="starwars" <cfif listFind(form.favoriteFilms,"starwars")>checked</cfif>>Star Wars</td> </tr> <tr valign="top"> <td><input type="checkbox" name="favoriteFilms" value="moulinrouge" <cfif listFind(form.favoriteFilms,"moulinrouge")>checked</cfif>>Moulin Rouge </td> <td><input type="checkbox" name="favoriteFilms" value="unbreakable" <cfif listFind(form.favoriteFilms,"unbreakable")>checked</cfif>>Unbreakable</td> </tr> <tr valign="top"> <td><input type="checkbox" name="favoriteFilms" value="matrix" <cfif listFind(form.favoriteFilms,"matrix")>checked</cfif>>The Matrix </td> <td><input type="checkbox" name="favoriteFilms" value="citizenkane" <cfif listFind(form.favoriteFilms,"citizenkane")>checked</cfif>>Citizen Kane</td> </tr> <tr valign="top"> <td><input type="checkbox" name="favoriteFilms" value="conversation" <cfif listFind(form.favoriteFilms,"conversation")>checked</cfif>>The Conversation </td> <td><input type="checkbox" name="favoriteFilms" value="heat" <cfif listFind(form.favoriteFilms,"heat")>checked</cfif>>Heat</td> </tr> </table> </td> </tr> <tr> <td> </td> <td><input type="submit" name="submit" value="Send Data"></td> </tr> </table> </form> </cfoutput> </cfif> </cfmodule> <!--- ** * CFMX Example Applications * * Copyright (c) 2002 Macromedia. All Rights Reserved. * * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA. * ** ---> <cfmodule template="../tags/layout.cfm" pageName="CFTRACE Example - Page Source"> <cfset variables.files = "index.cfm"> <cfinclude template="../tags/showsource.cfm"> </cfmodule> <!--- ** * CFMX Example Applications * * Copyright (c) 2002 Macromedia. All Rights Reserved. * * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA. * ** ---> <cfmodule template="../tags/bts_layout.cfm" exampleName="Data Drill-Down Example" source="index.cfm,results.cfm,detail.cfm" keyTags="cfquery@Tags78.html,cfset@Tags94.html,cfif cfelse cfelseif@Tags49.html,IsDefined()@Functions122.html"> <p> The Store Catalog example takes the basic search presented in the Personnel Directory one step further by displaying multiple matches to the initial search and allowing the user to "drill-down" to find more detail about each match. Notice information being passed from page to page in two different ways; via a form post and via a URL parameter. </p> <p> The example also demonstrates how to implement a "Prior/Next" link to allow a user to view a large set of results over multiple pages. </p> </cfmodule> <!--- ** * CFMX Example Applications * * Copyright (c) 2002 Macromedia. All Rights Reserved. * * YOUR RIGHTS WITH RESPECT TO THIS SOFTWARE IS GOVERNED BY THE * TERMS AND CONDITIONS SET FORTH IN THE CORRESPONDING EULA. * ** ---> <cfmodule template="../tags/layout.cfm" pageName="Data Drill-Down Example"> <!--- Now that we have a single item, we can select just that one record and display the full details. ---> <!--- Check for url.ItemID ---> <cfif not isDefined("url.itemID")> <!--- Send them away if not! ---> <cflocation url="index.cfm"> </cfif> <!--- request.app.dsn is a variable set in the root Application.cfm file. By setting the datasource name as a variable, it makes it very easy to change DSN names later on. ---> <cfquery name="TheItem" dataSource="#request.app.dsn#"> select tblCategories.CategoryName, tblItems.* from tblCategories, tblItems where tblCategories.CategoryID = tblItems.CategoryIDFK and tblItems.ItemID = '#url.itemID#' </cfquery> <!--- If the record didn't exist, send the user away "not TheItem.recordCount" will be true if the recordcount is 0. Not 0 is 1. ---> <cfif not TheItem.recordCount> <cflocation url="index.cfm"> </cfif> <p> By passing the item's ID as a URL parameter (notice the URL in your browser shows this page as detail.cfm?ItemID=XXXXXXX, where X is a long ID string), you can query the database for complete information about this ite